package com.责任链模式;

import java.util.ArrayList;
import java.util.List;

/**
 * 责任链模式工具类
 * @author Fang Ruichuan
 * @date 2022-09-03 13:19
 */
public class ChainOfResponsibilityClient {
    private List<Ratify> ratifies;

    public ChainOfResponsibilityClient() {
        ratifies = new ArrayList<>();
    }

    public void addRatify(Ratify ratify) {
        ratifies.add(ratify);
    }

    public Result execute(Request request) {
        List<Ratify> list = new ArrayList<>();
        list.addAll(ratifies);
        list.add(new GroupLeader());
        list.add(new Manager());
        list.add(new DepartmentLeader());
        RealChain realChain = new RealChain(request, list, 0);
        return realChain.proceed(request);
    }
}
